import 'package:demo/app/view/TakePictureView.dart';
import 'package:demo/app/view/VideoRightButtonView.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tencent_trtc_cloud/trtc_cloud_video_view.dart';

import 'home_controller.dart';

class HomeView extends GetView<HomeController> {
  const HomeView({super.key});

  @override
  Widget build(BuildContext context) {
    final state = controller.state;
    return Scaffold(
        body: Stack(
      children: [
        Container(
          width: Get.width,
          height: Get.height,
          decoration: const BoxDecoration(),
          child: state.showRemoteView
              ? TRTCCloudVideoView(
                  onViewCreated: (remoteViewId) {
                    state.remoteViewId = remoteViewId;
                    controller.startRemotePreview();
                  },
                )
              : Container(),
        ),
        const Positioned(right: 10, bottom: 20, child: VideoRightButtonView()),
        Positioned(
            right: 0,
            left: 0,
            bottom: 20,
            child: TakePictureView(
              onTap: () {
                controller.takePhoto();
              },
            )),
        Positioned(
            left: 20,
            bottom: 20,
            child: Container(
              width: 60,
              height: 60,
              decoration: BoxDecoration(color: Colors.white),
              child: Center(child: Text("相册还没写好")),
            )),
        Positioned(
          left: 20,
          bottom: 100,
          child: Column(
            children: [
              ElevatedButton(
                onPressed: () {
                  controller.enterRoom("userId1");
                },
                child: Text("进入房间userId1"),
              ),
              ElevatedButton(
                onPressed: () {
                  controller.enterRoom("userId2");
                },
                child: Text("进入房间userId2"),
              ),
            ],
          ),
        ),
      ],
    ));
  }
}
